package org.bee.service;

import jakarta.annotation.Resource;
import org.bee.mappers.AdminUserMapper;
import org.bee.model.AdminUser;
import org.bee.model.AdminUserExample;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 系统用户表Service层
 * 由bee-gen生成
 */
@Service
public class AdminUserService{
    @Resource
    private AdminUserMapper adminUserMapper;

    /**
     * 插入系统用户表
     * @param adminUser 系统用户表实体
     * @return 插入结果
     */
    public int insert(AdminUser adminUser) {
        return adminUserMapper.insert(adminUser);
    }

    /**
     * 删除系统用户表
     * @param adminUserId 系统用户表id
     * @return 删除结果
     */
    public int delete(String adminUserId,Boolean isDelete) {
        if(isDelete){
            return adminUserMapper.deleteByPrimaryKey(adminUserId);
        }else{
            AdminUser adminUser = new AdminUser();
            adminUser.setUserId(adminUserId);
            adminUser.setIsDeleted(true);
            return adminUserMapper.updateByPrimaryKeySelective(adminUser);
        }
    }

    /**
     * 根据主键更新系统用户表
     * @param adminUser 系统用户表实体
     * @return 更新结果
     */
    public int update(AdminUser adminUser) {
        return adminUserMapper.updateByPrimaryKeySelective(adminUser);
    }

    /**
     * 根据条件查询部门表
     * @param departmentExample 部门表查询条件
     * @return 部门表列表
     */
    public List<AdminUser> selectByExample(AdminUserExample departmentExample) {
        return adminUserMapper.selectByExample(departmentExample);
    }
}